<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>固化版本</title>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/easyui/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/easyui/themes/icon.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/buttons.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/autocomplete/jquery.autocomplete.css" />
<script type="text/javascript" src="${pageContext.request.contextPath}/easyui/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-form.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/easyui/datagrid-detailview.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/easyui/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/util/jquery.cookie.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/YMLib.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/autocomplete/jquery.autocomplete.js" ></script>
<style type="text/css">.table{border: 1px solid #FFE7BA;} .table tr{border: 1px solid #FFE7BA;} .table tr td{border: 1px solid #FFE7BA;}</style>
<script type="text/javascript">
function checkCf(){
    var nf=$("#nf").combobox('getValue');
    var yf=$("#yf").combobox('getValue');
    var ghny = nf+"-"+yf;
    var yhdzxcs={ghny:ghny}
	$.ajax({
            url:"/jxcsxm/tjbb/selectGhbbXmtjCf.do",
            data:yhdzxcs,
			type:'post',
            async:false,
			dataType:'json',
			success:function(msg){
				if(msg){
                    if(confirm("此版本已固化，是否要覆盖此版本重新固化?")){
                                    $.ajax({
                                        url:"/jxcsxm/tjbb/deleteGhXmtjbbByghny.do",
                                        data:yhdzxcs,
                                        type:'post',
                                        async:false,
                                        dataType:'json',
                                        success:function(msg){
                                            if(msg){
                                                addGhbbHx()
                                            }
                                        }
                                    })


                    }else{
                        // alert("点击了取消按钮");
                    }
				}else{
					addGhbbHx();
				}

			}
		})
}

$(function(){

	loadBmbm('nf','项目年份',new Date().getFullYear());
	var yf=new Date().getMonth()+1;
	var day=new Date().getDate();
	if(yf<10)loadBmbm('yf','月份',"0"+yf);else loadBmbm('yf','月份',yf);

})

function addGhbb(){

	var nf=$("#nf").combobox('getValue');
	var yf=$("#yf").combobox('getValue');

	if(nf==''||nf==null){
		alert("固化年份不能为空");
		return;
	}
	if(yf==''||yf==null){
		alert("固化月份不能为空");
		return;
	}
	// addGhbbHx();
	// var url="";
	// url="/jxcsxm/tjbb/importTjbb.do?gydwdm="+$.cookie("unit");

	checkCf();

}
function addGhbbHx(){
	// var yhdzxcs={'yhdzxcs.cslx':$('#addsellmjg').val(),'yhdzxcs.clmc':$('#txtclmc').val(),
	// 	'yhdzxcs.lfmdj':$('#txtlfmdj').val(),'yhdzxcs.bz':$('#txtbz').val(),'yhdzxcs.dw':$('#txtdw').val()};
	var nf=$("#nf").combobox('getValue');
	var yf=$("#yf").combobox('getValue');
	var ghny = nf+"-"+yf;
	var yhdzxcs={nf:nf,yf:yf}
	$.ajax({
		type:'post',
		async:false,
		url:"/jxcsxm/tjbb/addGhXmtjbbHx.do",
		data:yhdzxcs,
		dataType:'json',
		success:function(data){
			if(data){
				alert("固化成功！");
				// parent.("#ghny").val();
				// window.parent.frames.$("#ghny").val();
				// var cbbYear = window.parent.frames.document.getElementById("ghny");
				// var opt = window.parent.frames.document.createElement("option");
				// opt.innerHTML = ghny;
				// cbbYear.appendChild(opt);
				console.log(111);
				window.parent.frames.loadXmtjGhny('ghny');

				closeWindow();
				// $('#xtgl_flwbzbz_table').datagrid("reload");
			}
		}
	});
}

</script>
</head>
<body>

<table class='table' style="width: 100%; background-color: #FFE7BA; font-size: 12px"
			border="0" cellpadding="3" cellspacing="1">

			<tr height="28">
				<td align="right">固化年月：</td>
				<td><select id="nf" style="width: 80px;"></select>--<select id="yf" style="width: 80px;"></select></td>
			</tr>



			<tr style="height: 35px;">
				<td colspan="4" style="background-color: #ffffff;"align="center">
				<a id='mybuttion1' style="margin-left: 5px;margin-bottom: 1px;" href="javascript:addGhbb()" onmouseover="szgq('button button-tiny button-glow button-rounded button-raised button-primary','mybuttion1')" onmouseout="szgq('button button-tiny button-rounded button-raised button-primary','mybuttion1')"  class="button button-tiny button-rounded button-raised button-primary">开始固化</a>
				<a id='mybuttion2' style="margin-left: 5px;margin-bottom: 1px;" href="javascript:closeWindow()" onmouseover="szgq('button button-tiny button-glow button-rounded button-raised button-primary','mybuttion2')" onmouseout="szgq('button button-tiny button-rounded button-raised button-primary','mybuttion2')"  class="button button-tiny button-rounded button-raised button-primary">取消</a>
			</tr>

		</table>
</body>
</html>